/*
 * tela principal da aplicação
 *
 */

package view;

import controller.Controller;
import java.awt.Component;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/**
 *
 * @author PC
 */

public class Main extends javax.swing.JFrame {

    String tipo_arquivo_origem = null;
    
    //controller
    static Controller controller;

    /**
     * Creates new form tela_principal
     */
    public Main() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialog1 = new javax.swing.JDialog();
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        panel_title = new javax.swing.JPanel();
        label_title = new javax.swing.JLabel();
        panel_info = new javax.swing.JPanel();
        label_informacoes = new javax.swing.JLabel();
        panel_info_fields = new javax.swing.JPanel();
        label_mes = new javax.swing.JLabel();
        label_vendas = new javax.swing.JLabel();
        label_precos = new javax.swing.JLabel();
        label_vendedores = new javax.swing.JLabel();
        label_saida = new javax.swing.JLabel();
        text_field_vendas = new javax.swing.JTextField();
        text_field_precos = new javax.swing.JTextField();
        text_field_vendedores = new javax.swing.JTextField();
        text_field_saida = new javax.swing.JTextField();
        button_calc = new javax.swing.JButton();
        btFileChooserVendas = new javax.swing.JButton();
        btFileChooserPreços = new javax.swing.JButton();
        btFileChooserVendedores = new javax.swing.JButton();
        btFileChooserSaida = new javax.swing.JButton();
        combo_box_mes = new javax.swing.JComboBox();
        jPanel_radioButton = new javax.swing.JPanel();
        label_leitura = new javax.swing.JLabel();
        rb_TXT = new javax.swing.JRadioButton();
        rb_XML = new javax.swing.JRadioButton();

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setFocusable(false);

        panel_title.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        label_title.setFont(new java.awt.Font("Tahoma", 1, 22)); // NOI18N
        label_title.setForeground(new java.awt.Color(102, 102, 102));
        label_title.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_title.setText("SISTEMA DE GERAÇÃO DE COMISSÕES");

        javax.swing.GroupLayout panel_titleLayout = new javax.swing.GroupLayout(panel_title);
        panel_title.setLayout(panel_titleLayout);
        panel_titleLayout.setHorizontalGroup(
            panel_titleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_titleLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_title, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        panel_titleLayout.setVerticalGroup(
            panel_titleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_titleLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_title, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        panel_info.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        label_informacoes.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        label_informacoes.setText("Informações Necessárias:");

        panel_info_fields.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.white, null, java.awt.Color.blue, java.awt.Color.lightGray));

        label_mes.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        label_mes.setText("Mês");
        label_mes.setEnabled(false);

        label_vendas.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        label_vendas.setText("Arquivo de Vendas");
        label_vendas.setEnabled(false);

        label_precos.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        label_precos.setText("Arquivo de Preços");
        label_precos.setEnabled(false);

        label_vendedores.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        label_vendedores.setText("Arquivo de Vendedores");
        label_vendedores.setEnabled(false);

        label_saida.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        label_saida.setText("Arquivo de Saida");
        label_saida.setEnabled(false);

        text_field_vendas.setEnabled(false);

        text_field_precos.setEnabled(false);

        text_field_vendedores.setEnabled(false);

        text_field_saida.setEnabled(false);

        button_calc.setText("Calcular");
        button_calc.setEnabled(false);
        button_calc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_calcActionPerformed(evt);
            }
        });

        btFileChooserVendas.setText("localizar");
        btFileChooserVendas.setEnabled(false);
        btFileChooserVendas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFileChooserVendasActionPerformed(evt);
            }
        });

        btFileChooserPreços.setText("localizar");
        btFileChooserPreços.setEnabled(false);
        btFileChooserPreços.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFileChooserPreçosActionPerformed(evt);
            }
        });

        btFileChooserVendedores.setText("localizar");
        btFileChooserVendedores.setEnabled(false);
        btFileChooserVendedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFileChooserVendedoresActionPerformed(evt);
            }
        });

        btFileChooserSaida.setText("Salvar");
        btFileChooserSaida.setEnabled(false);
        btFileChooserSaida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFileChooserSaidaActionPerformed(evt);
            }
        });

        combo_box_mes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));
        combo_box_mes.setEnabled(false);
        combo_box_mes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_box_mesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panel_info_fieldsLayout = new javax.swing.GroupLayout(panel_info_fields);
        panel_info_fields.setLayout(panel_info_fieldsLayout);
        panel_info_fieldsLayout.setHorizontalGroup(
            panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_info_fieldsLayout.createSequentialGroup()
                .addGap(66, 66, 66)
                .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(label_vendas)
                    .addComponent(label_mes)
                    .addComponent(label_precos)
                    .addComponent(label_vendedores)
                    .addComponent(label_saida))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(button_calc)
                    .addGroup(panel_info_fieldsLayout.createSequentialGroup()
                        .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(combo_box_mes, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(text_field_vendas, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                            .addComponent(text_field_precos, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(text_field_vendedores, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(text_field_saida, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btFileChooserVendedores, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btFileChooserPreços, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btFileChooserVendas, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btFileChooserSaida, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(72, Short.MAX_VALUE))
        );
        panel_info_fieldsLayout.setVerticalGroup(
            panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_info_fieldsLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(combo_box_mes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_mes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_field_vendas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_vendas)
                    .addComponent(btFileChooserVendas))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_field_precos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_precos)
                    .addComponent(btFileChooserPreços))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_field_vendedores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_vendedores)
                    .addComponent(btFileChooserVendedores))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_saida)
                    .addGroup(panel_info_fieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(text_field_saida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btFileChooserSaida)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(button_calc)
                .addContainerGap(46, Short.MAX_VALUE))
        );

        panel_info_fieldsLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {label_mes, label_precos, label_saida, label_vendas, label_vendedores});

        jPanel_radioButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        label_leitura.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        label_leitura.setText("Tipo de Arquivo:");

        buttonGroup1.add(rb_TXT);
        rb_TXT.setText("TXT");
        rb_TXT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_TXTActionPerformed(evt);
            }
        });

        buttonGroup1.add(rb_XML);
        rb_XML.setText("XML");
        rb_XML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_XMLActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel_radioButtonLayout = new javax.swing.GroupLayout(jPanel_radioButton);
        jPanel_radioButton.setLayout(jPanel_radioButtonLayout);
        jPanel_radioButtonLayout.setHorizontalGroup(
            jPanel_radioButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_radioButtonLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel_radioButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_leitura)
                    .addComponent(rb_TXT, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rb_XML, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        jPanel_radioButtonLayout.setVerticalGroup(
            jPanel_radioButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_radioButtonLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(label_leitura)
                .addGap(18, 18, 18)
                .addComponent(rb_TXT)
                .addGap(18, 18, 18)
                .addComponent(rb_XML)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panel_infoLayout = new javax.swing.GroupLayout(panel_info);
        panel_info.setLayout(panel_infoLayout);
        panel_infoLayout.setHorizontalGroup(
            panel_infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_infoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panel_infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_infoLayout.createSequentialGroup()
                        .addComponent(label_informacoes)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(panel_infoLayout.createSequentialGroup()
                        .addComponent(jPanel_radioButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                        .addComponent(panel_info_fields, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        panel_infoLayout.setVerticalGroup(
            panel_infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_infoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_informacoes)
                .addGap(18, 18, 18)
                .addGroup(panel_infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(panel_info_fields, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel_radioButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel_title, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel_info, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panel_title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panel_info, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // funções de escuta dos objs visuais
    private void button_calcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_calcActionPerformed

        controller = new Controller();

        String mes = (String) combo_box_mes.getSelectedItem();

        String vendas_path = text_field_vendas.getText();
        String precos_path = text_field_precos.getText();
        String vendedores_path = text_field_vendedores.getText();
        String saida_path = text_field_saida.getText();

        String msgArquivos = ValidaMain.validaArquivos(vendas_path, precos_path, vendedores_path, saida_path);

        if ("".equals(msgArquivos)) {
            //chama o controler.java
            //aqui vamos passar as urls que devem ser carregadas
            try {
                controller.calculaComissoes(mes, vendas_path, precos_path, vendedores_path, saida_path, tipo_arquivo_origem);
                JOptionPane.showMessageDialog(this, "Arquivo salvo com sucesso !");
            } catch (Exception e) {
                System.out.println("erro " + e.getMessage());
                JOptionPane.showMessageDialog(this, "Erro, por favor verifique as entradas", "ERRO", JOptionPane.ERROR_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(this, msgArquivos);
        }
    }//GEN-LAST:event_button_calcActionPerformed

    public String geraCaminho() {
        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showOpenDialog(null);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File arq = chooser.getSelectedFile().getAbsoluteFile();
            String caminho = arq.getPath();
            return caminho;
        } else {
            return "Selecione um arquivo";
        }
    }

    public String geraDiretorio() {
        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showSaveDialog(null);
        File arq = chooser.getSelectedFile().getAbsoluteFile();
        String caminho = arq.getPath();
        return caminho;
    }

    private void btFileChooserVendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFileChooserVendasActionPerformed

        FileChooser f = new FileChooser();
        f.setDefaultCloseOperation(HIDE_ON_CLOSE);
        text_field_vendas.setText(geraCaminho());
    }//GEN-LAST:event_btFileChooserVendasActionPerformed

    private void btFileChooserVendedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFileChooserVendedoresActionPerformed

        FileChooser f = new FileChooser();
        f.setDefaultCloseOperation(HIDE_ON_CLOSE);
        text_field_vendedores.setText(geraCaminho());
}//GEN-LAST:event_btFileChooserVendedoresActionPerformed

    private void btFileChooserPreçosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFileChooserPreçosActionPerformed

        FileChooser f = new FileChooser();
        f.setDefaultCloseOperation(HIDE_ON_CLOSE);
        text_field_precos.setText(geraCaminho());
}//GEN-LAST:event_btFileChooserPreçosActionPerformed

    private void btFileChooserSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFileChooserSaidaActionPerformed

        FileChooser f = new FileChooser();
        f.setDefaultCloseOperation(HIDE_ON_CLOSE);
        text_field_saida.setText(geraDiretorio());
    }//GEN-LAST:event_btFileChooserSaidaActionPerformed

    public void enabledPanelFiles() {
        Component[] comps = panel_info_fields.getComponents();
        for (int i = 0; i < comps.length; i++) {
            //System.out.println(comps[i]);
            if (comps[i] instanceof javax.swing.JTextField
                    || comps[i] instanceof javax.swing.JLabel
                    || comps[i] instanceof javax.swing.JButton
                    || comps[i] instanceof javax.swing.JComboBox) {
                comps[i].setEnabled(true);
            }
        }
    }

    public String selectTypeFile() {
        try {
            if (rb_TXT.isSelected()) {
                enabledPanelFiles();
                return "TXT";
            }
            if (rb_XML.isSelected()) {
                enabledPanelFiles();
                return "XML";
            }
        } catch (Exception e) {
            return e.getMessage();
        }
        return ("Deu Problema");
    }

    private void rb_TXTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_TXTActionPerformed

        tipo_arquivo_origem = selectTypeFile();
    }//GEN-LAST:event_rb_TXTActionPerformed

    private void rb_XMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_XMLActionPerformed

        tipo_arquivo_origem = selectTypeFile();
    }//GEN-LAST:event_rb_XMLActionPerformed

   
    
    private void combo_box_mesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_box_mesActionPerformed


        combo_box_mes.addItemListener(new ItemListener() {
            
            public void itemStateChanged(ItemEvent ie) {
                String str = (String) combo_box_mes.getSelectedItem();
                
            }
        });

    }//GEN-LAST:event_combo_box_mesActionPerformed
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Main().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btFileChooserPreços;
    private javax.swing.JButton btFileChooserSaida;
    private javax.swing.JButton btFileChooserVendas;
    private javax.swing.JButton btFileChooserVendedores;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton button_calc;
    private javax.swing.JComboBox combo_box_mes;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JPanel jPanel_radioButton;
    private javax.swing.JLabel label_informacoes;
    private javax.swing.JLabel label_leitura;
    private javax.swing.JLabel label_mes;
    private javax.swing.JLabel label_precos;
    private javax.swing.JLabel label_saida;
    private javax.swing.JLabel label_title;
    private javax.swing.JLabel label_vendas;
    private javax.swing.JLabel label_vendedores;
    private javax.swing.JPanel panel_info;
    private javax.swing.JPanel panel_info_fields;
    private javax.swing.JPanel panel_title;
    private javax.swing.JRadioButton rb_TXT;
    private javax.swing.JRadioButton rb_XML;
    private javax.swing.JTextField text_field_precos;
    private javax.swing.JTextField text_field_saida;
    private javax.swing.JTextField text_field_vendas;
    private javax.swing.JTextField text_field_vendedores;
    // End of variables declaration//GEN-END:variables
}
